package com.dhcc.wb.articleday;

import java.util.List;

import com.dhcc.bussiness.page.PageBean;
import com.dhcc.wb.articleliushui.ArticleLiushuiDao;
import com.dhcc.wb.articleliushui.ArticleShowModel;

public class ArticleDayService {
	
	/**
	 * 每日流水列表页面展示
	 * @return
	 */
	public PageBean<ArticleModel> findArticleServiceByPage(int currentPage, int currentCount,String title,String gzhname) {
		ArticledayDao dao = new ArticledayDao();
		PageBean<ArticleModel> pageBean = new PageBean<ArticleModel>();
		try {
			pageBean.setCurrentPage(currentPage);
			pageBean.setCurrentCount(currentCount);
			Integer totalCount = dao.queryCount(title);
			pageBean.setTotalCount(totalCount);
			int totalPage = (int) Math.ceil(1.0*totalCount/currentCount);
			pageBean.setTotalPage(totalPage);
			int startIndex = (currentPage-1)*currentCount;
			List<ArticleModel> pageList = dao.findArticleDayServiceByPage(startIndex, currentCount, title,gzhname);
			pageBean.setPageList(pageList);
		}catch (Exception e) {
			e.printStackTrace();
		}
		return pageBean;
	}
	
	/**
	 * 后台文章列表显示
	 * @return
	 */
	public PageBean<ArticleShowModel> findArticleShowServiceByPage(int currentPage, int currentCount,String title) {
		ArticledayDao dao = new ArticledayDao();
		PageBean<ArticleShowModel> pageBean = new PageBean<ArticleShowModel>();
		try {
			pageBean.setCurrentPage(currentPage);
			pageBean.setCurrentCount(currentCount);
			Integer totalCount = dao.queryCount(title);
			pageBean.setTotalCount(totalCount);
			int totalPage = (int) Math.ceil(1.0*totalCount/currentCount);
			pageBean.setTotalPage(totalPage);
			int startIndex = (currentPage-1)*currentCount;
			List<ArticleShowModel> pageList = dao.findArticleServiceByPage(startIndex, currentCount, title);
			pageBean.setPageList(pageList);
		}catch (Exception e) {
			e.printStackTrace();
		}
		return pageBean;
	}
}